package com.solo.system.dubbo;

import com.mybatisflex.core.query.QueryChain;
import com.solo.system.api.SysRoleDeptApi;
import com.solo.system.mapper.SysRoleDeptMapper;
import lombok.RequiredArgsConstructor;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Set;

import static com.solo.system.api.entity.table.SysRoleDeptTableDef.SysRoleDeptTable;

/**
 * 系统角色部门远程调用实现类
 * @author 十一
 * @since 2024/11/28
 * 人生若只如初见，何事秋风悲画扇
 **/
@Service
@DubboService
@RequiredArgsConstructor
public class SysRoleDeptApiImpl implements SysRoleDeptApi {
    
    private final SysRoleDeptMapper sysRoleDeptMapper;

    @Override
    public List<Long> selectDeptIds(Set<Long> roleIds) {
        return QueryChain.of(sysRoleDeptMapper)
                .select(SysRoleDeptTable.DeptId)
                .from(SysRoleDeptTable)
                .where(SysRoleDeptTable.RoleId.in(roleIds))
                .listAs(Long.class);
    }

}
